remove the last character from a string in php

82

phpCopy<?php
$mystring = "This is a PHP program.";
echo substr($mystring, 0, -1);
?>
phpCopy<?php
$mystring = "This is a PHP program.";
echo("This is the string before removal: $mystring\n");
$newstring = rtrim($mystring, ". ");
echo("This is the string after removal: $newstring");
?>

Comments

Submit
0 Comments